package com.project.lk.nurseapp.msg.presenter;

import com.project.lk.nurseapp.base.BaseApi;
import com.project.lk.nurseapp.base.BasePresenter;
import com.project.lk.nurseapp.base.ModelPresenterBridge;
import com.project.lk.nurseapp.msg.model.AppMsgItemBean;
import com.project.lk.nurseapp.msg.model.AppMsgModel;

import java.util.List;

/**
 * 功能介绍：
 * 项目名：
 * 模块名称：
 * 作者：LK
 * 日期：2018/1/9
 * 修改日期：
 */
public class AppMsgPresenter extends BasePresenter<IAppMsgView> implements ModelPresenterBridge {

    AppMsgModel appMsgModel;
    public AppMsgPresenter(IAppMsgView view){
        appMsgModel=new AppMsgModel();
        appMsgModel.setBridge(this);
        addView(view);

    }

    public List<AppMsgItemBean> getList(){
        return appMsgModel.getmList();
    }

    public void refresh(String url){
        appMsgModel.refresh();
        appMsgModel.postLoadJson(url);

    }

    public void loadMore(String url){
        appMsgModel.loadMore();
        appMsgModel.postLoadJson(url);
    }

    @Override
    public void bridge(int action, List list) {
        if (view!=null) {
            switch (action){
                case BaseApi.show_list:
                    view.showList();
                    break;
                case BaseApi.fail:
                    view.fail();
                    break;
                case BaseApi.noMore:
                    view.noMore();
                    break;
            }
        }
    }
}
